import React from 'react';

import { TouchableOpacity } from 'react-native';

export default class Touchable extends React.Component {
ToPress =() => {
  const { onPress } = this.props;
  if (this.lastPressed && this.lastPressed + 500 >= Date.now()) {
    return;
  }
  this.lastPressed = Date.now();
  onPress && onPress();
}

render() {
  return (
    <TouchableOpacity
      activeOpacity={0.85}
      {...this.props}
      onPress={this.ToPress}
    />
  );
}
}
